package com.example.beidouapplication;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import androidx.annotation.Nullable;

import com.example.beidouapplication.viewmodel.Key;
import com.example.beidouapplication.viewmodel.KeyEvent;


public class FragmentDaohang extends Fragment {

    static FragmentDaohang instance = new FragmentDaohang();
    Button btn_daohang_guandao;
    Button btn_daohang_beidou;

    @Override
    public View onCreateView(
            LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState
    ) {

//        View inflate = inflater.inflate(R.layout.fragment_content_guandao, container, false);
        View inflate = inflater.inflate(R.layout.fragment_content_daohang, container, false);
        return inflate;
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        btn_daohang_guandao = (Button) getActivity().findViewById(R.id.btn_daohang_guandao);
        btn_daohang_guandao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Menu.keyQueue.add(new KeyEvent(Key.ENTER, 1));
                getChildFragmentManager().beginTransaction().replace(R.id.daohang_contentFrame, FragmentDaohangGuandao.instance).commit();

            }
        });

        btn_daohang_beidou = (Button) getActivity().findViewById(R.id.btn_daohang_beidou);
        btn_daohang_beidou.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Menu.keyQueue.add(new KeyEvent(Key.ENTER, 2));
                getChildFragmentManager().beginTransaction().replace(R.id.daohang_contentFrame, FragmentDaohangBeidou.instance).commit();

            }
        });

        getChildFragmentManager().beginTransaction().replace(R.id.daohang_contentFrame, FragmentDaohangGuandao.instance).commit();
        getChildFragmentManager().beginTransaction().replace(R.id.daohang_contentFrame2, FragmentDaohangBeidou.instance).commit();
    }


}